import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from "path";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver, AntDesignVueResolver } from "unplugin-vue-components/resolvers";
import legacy from '@vitejs/plugin-legacy';
import { createStyleImportPlugin, AndDesignVueResolve } from 'vite-plugin-style-import';

// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  plugins: [vue(),
  legacy(),
  Components({
    resolvers: [ElementPlusResolver(), AntDesignVueResolver({ importStyle: false })],
  }),
  createStyleImportPlugin({
    resolves: [AndDesignVueResolve()],
    libs: [
      {
        libraryName: 'ant-design-vue',
        esModule: true,
        resolveStyle: (name: string) => {
          return `ant-design-vue/es/${name}/style/index`
        }
      },
    ],
  })
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
      "*": path.resolve(""),
    },
  },
  server: {
    host: "0.0.0.0",
  }
})
